<template>
  <div>
    <table-title></table-title>
    <h1>子组件</h1>
    <h1>{{food}}</h1>
     <h1>{{car}}</h1>
     <button @click="toSend">子传父</button>
  </div>
</template>

<script setup>
  import {defineProps,defineEmits,ref} from 'vue'
    // setup语法糖中defineProps 定义props 并传值
    // let props=defineProps(["food","car"])
    let emit=defineEmits(['sendmsg']);
    
    let fdata=ref("我要吃烧烤")
    let  toSend=()=>{
      emit("sendmsg",fdata.value)
    }
      
     let props=defineProps({
      food:{
        type:String,
        default:"火锅"
      },
      car:{
         type:String,
        default:"宝马"
      }
     })
    //在js中使用父传子的数据
    console.log(props.food)
    console.log(props.car)


</script>
